using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NET.Library.Types;

namespace NET.Library.Web.Forms.DataControls.GridViews
{
    /// <summary>
    /// GridViewValues Object
    /// </summary>
    public class GridViewValues : NET.Library.Types.Strings
    {
        #region Static Methods
        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert GridView's DataKeys collection item as an Integer
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <returns>Integer</returns>
        /// '-----------------------------------------------------------------------------------------
        public static int IntDataKeys(GridView gridView, GridViewUpdateEventArgs e)
        {
            return (!IsEmptyString(gridView.DataKeys[e.RowIndex].Value.ToString())) ? Convert.ToInt32(gridView.DataKeys[e.RowIndex].Value) : int.MinValue;
            //GridViewRow row = gridView.Rows[e.RowIndex];
            //return (!IsEmptyString(gridView.DataKeys
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static int IntDataKeys(GridView gridView, GridViewDeleteEventArgs e)
        {
            return (!IsEmptyString(gridView.DataKeys[e.RowIndex].Value.ToString())) ? Convert.ToInt32(gridView.DataKeys[e.RowIndex].Value) : int.MinValue;
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert GridView's DataKeys collection item as an Integer
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="dataKeyIndex"></param>
        /// <returns>Integer</returns>
        /// '-----------------------------------------------------------------------------------------
        public static int IntDataKeys(GridView gridView, int dataKeyIndex)
        {
            return (!IsEmptyString(gridView.DataKeys[dataKeyIndex].Value.ToString())) ? Convert.ToInt32(gridView.DataKeys[dataKeyIndex].Value) : int.MinValue;
        }
        //public static int intDataKeys(GridView gridView, GridViewUpdateEventArgs e, int dataKeyIndex)
        //{
        //    return (!IsEmptyString(gridView.DataKeys[dataKeyIndex].Value.ToString())) ? Convert.ToInt32(gridView.DataKeys[dataKeyIndex].Value) : int.MinValue;
        //}

        #region TextBox Controls
        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert TextBox text in a GridView to an Integer value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="textBoxName"></param>
        /// <returns>Integer</returns>
        /// '-----------------------------------------------------------------------------------------
        public static int IntTextBoxValue(GridView gridView, GridViewUpdateEventArgs e, string textBoxName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            TextBox textBox = GridViewControls.TextBoxControl(textBoxName, row);
                //(TextBox)(row.FindControl(textBoxName));
            return Values.IntTextValue(textBox);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert TextBox text in a GridViewRow to an Integer value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="textBoxName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static int IntTextBoxValue(GridViewRow row, string textBoxName)
        {
            //TextBox textBox = GridViewControls.TextBoxControl(textBoxName, row);
                //(TextBox)(row.FindControl(textBoxName));
            return Values.IntTextValue(GridViewControls.TextBoxControl(textBoxName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert TextBox text in a GridView to a Decimal value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="textBoxName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static decimal DecimalTextBoxValue(GridView gridView, GridViewUpdateEventArgs e, string textBoxName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            TextBox textBox = GridViewControls.TextBoxControl(textBoxName, row);
                //(TextBox)(row.FindControl(textBoxName));
            return Values.DecimalTextValue(textBox);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert TextBox text in a GridViewRow to a Decimal value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="textBoxName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static decimal DecimalTextBoxValue(GridViewRow row, string textBoxName)
        {
            //TextBox textBox = GridViewControls.TextBoxControl(textBoxName, row);
                //(TextBox)(row.FindControl(textBoxName));
            return Values.DecimalTextValue(GridViewControls.TextBoxControl(textBoxName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Get TextBox text in a GridView to a string value by using the FCS method Values.StringTextValue
        /// to remove invalid characters and trim the string.
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="textBoxName"></param>
        /// <returns>string</returns>
        /// <remarks></remarks>
        /// <example></example>
        /// '-----------------------------------------------------------------------------------------
        public static string StringTextBoxValue(GridView gridView, GridViewUpdateEventArgs e, string textBoxName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            TextBox textBox = GridViewControls.TextBoxControl(textBoxName, row);
                //(TextBox)(row.FindControl(textBoxName));
            return Values.StringTextValue(textBox);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Get TextBox text in a GridViewRow to a string value by using the FCS method Values.StringTextValue
        /// to remove invalid characters and trim the string.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="textBoxName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static string StringTextBoxValue(GridViewRow row, string textBoxName)
        {
            //TextBox textBox = GridViewControls.TextBoxControl(textBoxName, row);
                //(TextBox)(row.FindControl(textBoxName));
            return Values.StringTextValue(GridViewControls.TextBoxControl(textBoxName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert TextBox text in a GridView to a DateTime value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="textBoxName"></param>
        /// <returns>DateTime</returns>
        /// <remarks></remarks>
        /// <example></example>
        /// '-----------------------------------------------------------------------------------------
        public static DateTime DateTimeTextBoxValue(GridView gridView, GridViewUpdateEventArgs e, string textBoxName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            TextBox textBox = GridViewControls.TextBoxControl(textBoxName, row);
                //(TextBox)(row.FindControl(textBoxName));

            if (IsEmptyString(Values.StringTextValue(textBox)))
            {
                return DateTimes.MinDateTime;
            }
            else
            {
                return Values.DateTimeTextValue(textBox);
            }
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert TextBox text in a GridViewRow to a DateTime value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="textBoxName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static DateTime DateTimeTextBoxValue(GridViewRow row, string textBoxName)
        {
            TextBox textBox = GridViewControls.TextBoxControl(textBoxName, row);
                //(TextBox)(row.FindControl(textBoxName));

            if (IsEmptyString(Values.StringTextValue(textBox)))
            {
                return DateTimes.MinDateTime;
            }
            else
            {
                return Values.DateTimeTextValue(textBox);
            }
        }
        #endregion

        #region Label Controls
        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Label text in a GridView to an Integer value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="labelName"></param>
        /// <returns>Integer</returns>
        /// <remarks></remarks>
        /// <example></example>
        /// '-----------------------------------------------------------------------------------------
        public static int IntLabelValue(GridView gridView, GridViewUpdateEventArgs e, string labelName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            Label label = GridViewControls.LabelControl(labelName, row);
                //(Label)(row.FindControl(labelName));
            return Values.IntTextValue(label);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Label text in a GridViewRow to an Integer value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="labelName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static int IntLabelValue(GridViewRow row, string labelName)
        {
            //Label label = GridViewControls.LabelControl(labelName, row);
            //(Label)(row.FindControl(labelName));
            return Values.IntTextValue(GridViewControls.LabelControl(labelName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Label text in a GridView to a Decimal value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="labelName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static decimal DecimalLabelValue(GridView gridView, GridViewUpdateEventArgs e, string labelName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            Label label = GridViewControls.LabelControl(labelName, row);
            //(Label)(row.FindControl(labelName));
            return Values.DecimalTextValue(label);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Label text in a GridViewRow to a Decimal value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="labelName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static decimal DecimalLabelValue(GridViewRow row, string labelName)
        {
            //Label label = GridViewControls.LabelControl(labelName, row);
            //(Label)(row.FindControl(labelName));
            return Values.DecimalTextValue(GridViewControls.LabelControl(labelName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Get Label text in a GridView to a string value by using the FCS method Values.StringTextValue
        /// to remove invalid characters and trim the string.
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="labelName"></param>
        /// <returns>string</returns>
        /// <remarks></remarks>
        /// <example></example>
        /// '-----------------------------------------------------------------------------------------
        public static string StringLabelValue(GridView gridView, GridViewUpdateEventArgs e, string labelName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            Label label = GridViewControls.LabelControl(labelName, row);
            //(Label)(row.FindControl(labelName));
            return Values.StringTextValue(label);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Get Label text in a GridViewRow to a string value by using the FCS method Values.StringTextValue
        /// to remove invalid characters and trim the string.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="labelName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static string StringLabelValue(GridViewRow row, string labelName)
        {
            //Label label = GridViewControls.LabelControl(labelName, row);
            //(Label)(row.FindControl(labelName));
            return Values.StringTextValue(GridViewControls.LabelControl(labelName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Label text in a GridView to a datetime value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="labelName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static DateTime DateTimeLabelValue(GridView gridView, GridViewUpdateEventArgs e, string labelName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            Label label = GridViewControls.LabelControl(labelName, row);
            //(Label)(row.FindControl(labelName));
            return Values.DateTimeTextValue(label);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Label text in a GridViewRow to a datetime value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="labelName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static DateTime DateTimeLabelValue(GridViewRow row, string labelName)
        {
            //Label label = GridViewControls.LabelControl(labelName, row);
            //(Label)(row.FindControl(labelName));
            return Values.DateTimeTextValue(GridViewControls.LabelControl(labelName, row));
        }
        #endregion

        #region Literal Controls
        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Literal text in a GridView to an int value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="literalName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static int IntLiteralValue(GridView gridView, GridViewUpdateEventArgs e, string literalName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            Literal Literal = GridViewControls.LiteralControl(literalName, row);
            //(Literal)(row.FindControl(LiteralName));
            return Values.IntTextValue(Literal);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Literal text in a GridViewRow to an int value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="literalName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static int IntLiteralValue(GridViewRow row, string literalName)
        {
            //Literal Literal = GridViewControls.LiteralControl(literalName, row);
            //(Literal)(row.FindControl(LiteralName));
            return Values.IntTextValue(GridViewControls.LiteralControl(literalName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Literal text in a GridView to a decimal value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="literalName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static decimal DecimalLiteralValue(GridView gridView, GridViewUpdateEventArgs e, string literalName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            Literal Literal = GridViewControls.LiteralControl(literalName, row);
            //(Literal)(row.FindControl(LiteralName));
            return Values.DecimalTextValue(Literal);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Literal text in a GridViewRow to a decimal value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="literalName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static decimal DecimalLiteralValue(GridViewRow row, string literalName)
        {
            //Literal Literal = GridViewControls.LiteralControl(literalName, row);
            //(Literal)(row.FindControl(LiteralName));
            return Values.DecimalTextValue(GridViewControls.LiteralControl(literalName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Get Literal text in a GridView to a string value by using the FCS method Values.StringTextValue
        /// to remove invalid characters and trim the string.
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="literalName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static string StringLiteralValue(GridView gridView, GridViewUpdateEventArgs e, string literalName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            Literal Literal = GridViewControls.LiteralControl(literalName, row);
            //(Literal)(row.FindControl(LiteralName));
            return Values.StringTextValue(Literal);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Get Literal text in a GridView to a string value by using the FCS method Values.StringTextValue
        /// to remove invalid characters and trim the string.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="literalName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static string StringLiteralValue(GridViewRow row, string literalName)
        {
            //Literal Literal = GridViewControls.LiteralControl(literalName, row);
            //(Literal)(row.FindControl(LiteralName));
            return Values.StringTextValue(GridViewControls.LiteralControl(literalName, row));
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Literal text in a GridView to a DateTime value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="literalName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static DateTime DateTimeLiteralValue(GridView gridView, GridViewUpdateEventArgs e, string literalName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            Literal Literal = GridViewControls.LiteralControl(literalName, row);
            //(Literal)(row.FindControl(LiteralName));
            return Values.DatetimeTextValue(Literal);
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert Literal text in a GridViewRow to a DateTime value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="literalName"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static DateTime DateTimeLiteralValue(GridViewRow row, string literalName)
        {
            //Literal Literal = ;
            //(Literal)(row.FindControl(LiteralName));
            return Values.DatetimeTextValue(GridViewControls.LiteralControl(literalName, row));
        }
        #endregion

        ///// '-----------------------------------------------------------------------------------------
        ///// <summary>
        ///// Convert Label text in a GridView to a DateTime
        ///// </summary>
        ///// <param name="gridView"></param>
        ///// <param name="e"></param>
        ///// <param name="labelName"></param>
        ///// <returns>DateTime</returns>
        ///// <remarks></remarks>
        ///// <example></example>
        ///// '-----------------------------------------------------------------------------------------
        //public static DateTime dtLabelVal(GridView gridView, GridViewUpdateEventArgs e, string labelName)
        //{
        //    GridViewRow row = gridView.Rows[e.RowIndex];
        //    Label label = (Label)(row.FindControl(labelName));
        //    return Values.dtTextVal(label);
        //}

        ///// '-----------------------------------------------------------------------------------------
        ///// <summary>
        ///// Convert Literal text in a GridView to a string
        ///// </summary>
        ///// <param name="gridView"></param>
        ///// <param name="e"></param>
        ///// <param name="literalName"></param>
        ///// <returns>string</returns>
        ///// <remarks></remarks>
        ///// <example></example>
        ///// '-----------------------------------------------------------------------------------------
        //public static string strTextVal(GridView gridView, GridViewUpdateEventArgs e, string literalName)
        //{
        //    Literal literal = (Literal)(e.Item.FindControl(literalName));
        //    return Values.strTextVal(literal);
        //}

        ///// '-----------------------------------------------------------------------------------------
        ///// 'Returns integer value from Literal text in a DataGrid
        ///// '-----------------------------------------------------------------------------------------
        ///// <summary>
        ///// Convert Literal text in a GridView to an Integer
        ///// </summary>
        ///// <param name="gridView"></param>
        ///// <param name="e"></param>
        ///// <param name="literalName"></param>
        ///// <returns></returns>
        ///// <remarks></remarks>
        ///// <example></example>
        //public static int intTextVal(GridView gridView, GridViewUpdateEventArgs e, string literalName)
        //{
        //    Literal literal = (Literal)(e.Item.FindControl(literalName));
        //    return Values.intTextVal(literal);
        //}

        ///// '-----------------------------------------------------------------------------------------
        ///// <summary>
        ///// Convert Literal text in a GridView to a DateTime
        ///// </summary>
        ///// <param name="gridView"></param>
        ///// <param name="e"></param>
        ///// <param name="literalName"></param>
        ///// <returns></returns>
        ///// <remarks></remarks>
        ///// <example>DateTime</example>
        ///// '-----------------------------------------------------------------------------------------
        //public static DateTime dtTextVal(GridView gridView, GridViewUpdateEventArgs e, string literalName)
        //{
        //    Literal literal = (Literal)(e.Item.FindControl(literalName));
        //    return Values.dtTextVal(literal);
        //}

        ///// '-----------------------------------------------------------------------------------------
        ///// <summary>
        ///// Convert selected CheckBox fields in a GridView to an integer
        ///// </summary>
        ///// <param name="gridView"></param>
        ///// <param name="e"></param>
        ///// <param name="checkBoxName"></param>
        ///// <returns></returns>
        ///// <remarks></remarks>
        ///// <example>integer, 1 if selected, 0 if not</example>
        ///// '-----------------------------------------------------------------------------------------
        //public static int intChkboxVal(GridView gridView, GridViewUpdateEventArgs e, string checkBoxName)
        //{
        //    return CheckBox.Checked == true ? 1 : 0;
        //}

        ///// '-----------------------------------------------------------------------------------------
        ///// <summary>
        ///// Convert radiobuttonlist selected value in a GridView to an integer
        ///// </summary>
        ///// <param name="gridView"></param>
        ///// <param name="e"></param>
        ///// <param name="radioButtonListName"></param>
        ///// <returns></returns>
        ///// <remarks></remarks>
        ///// <example>integer</example>
        ///// '-----------------------------------------------------------------------------------------
        //public static int intRadioListVal(GridView gridView, GridViewUpdateEventArgs e, string radioButtonListName)
        //{
        //    return RadioButtonList.SelectedItem != null ? Convert.ToInt32(RadioButtonList.SelectedItem.Value) : int.MinValue;
        //}

        #region DropDownList Controls
        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Convert DropDownList selected value in a GridView to an integer value
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="e"></param>
        /// <param name="dropDownListName"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        /// <example>integer</example>
        /// '-----------------------------------------------------------------------------------------
        public static int IntDropDownListValue(GridView gridView, GridViewUpdateEventArgs e, string dropDownListName)
        {
            GridViewRow row = gridView.Rows[e.RowIndex];
            DropDownList dropDownList = GridViewControls.DropDownListControl(dropDownListName, row);
            //(DropDownList)(row.FindControl(dropDownListName));
            return dropDownList.SelectedItem != null ? Convert.ToInt32(dropDownList.SelectedItem.Value) : int.MinValue;
        }

        /// <summary>
        /// Convert DropDownList selected value in a GridViewRow to an integer value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="dropDownListName"></param>
        /// <returns></returns>
        public static int IntDropDownListValue(GridViewRow row, string dropDownListName)
        {
            DropDownList dropDownList = GridViewControls.DropDownListControl(dropDownListName, row);
            //(DropDownList)(row.FindControl(dropDownListName));
            return dropDownList.SelectedItem != null ? Convert.ToInt32(dropDownList.SelectedItem.Value) : int.MinValue;
        }

        ///// '-----------------------------------------------------------------------------------------
        ///// <summary>
        ///// Convert DropDownList selected text in a GridView to a string
        ///// </summary>
        ///// <param name="gridView"></param>
        ///// <param name="e"></param>
        ///// <param name="dropDownListName"></param>
        ///// <returns>string</returns>
        ///// <remarks></remarks>
        ///// <example></example>
        ///// '-----------------------------------------------------------------------------------------
        //public static string strDropDownListText(GridView gridView, GridViewUpdateEventArgs e, string dropDownListName)
        //{
        //    return DropDownList.SelectedItem != null ? RemoveInvalidChar(DropDownList.SelectedItem.Text) : String.Empty;
        //}
        #endregion

        /// <summary>
        /// Used in replacing an empty cell with the html encoded space character
        /// </summary>
        /// <param name="e"></param>
        /// <param name="columnName"></param>
        /// <param name="label"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        /// <example>
        /// Label myLabel = (Label)e.Row.FindControl("myLabel");
        /// myLabel.Text = GridViewValues.replaceEmptyText(e, "myColumnName", myLabel);
        /// </example>
        /// '-----------------------------------------------------------------------------------------
        public static string ReplaceEmptyText(GridViewRowEventArgs e, string columnName, Label label)
        {
            if (Strings.IsEmptyString(DataBinder.Eval(e.Row.DataItem, columnName).ToString()))
                return "&nbsp;";
            else
                return label.Text;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="row"></param>
        /// <param name="columnName"></param>
        /// <param name="label"></param>
        /// <returns></returns>
        public static string ReplaceEmptyText(GridViewRow row, string columnName, Label label)
        {
            if (Strings.IsEmptyString(DataBinder.Eval(row.DataItem, columnName).ToString()))
                return "&nbsp;";
            else
                return label.Text;
        }

        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Used in replacing an empty cell with the html encoded space character
        /// </summary>
        /// <param name="e"></param>
        /// <param name="columnName"></param>
        /// <param name="labelName"></param>
        /// <remarks></remarks>
        /// <example>
        /// GridViewValues.replaceEmptyLabel(e, "myColumnName", "myLabelName");
        /// </example>
        /// '-----------------------------------------------------------------------------------------
        public static void ReplaceEmptyLabel(GridViewRowEventArgs e, string columnName, string labelName)
        {
            Label label = (Label)e.Row.FindControl(labelName);
            label.Text = ReplaceEmptyText(e, columnName, label);

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="row"></param>
        /// <param name="columnName"></param>
        /// <param name="labelName"></param>
        public static void ReplaceEmptyLabel(GridViewRow row, string columnName, string labelName)
        {
            Label label = (Label)row.FindControl(labelName);
            label.Text = ReplaceEmptyText(row, columnName, label);

        }

        ///// <summary>
        ///// 
        ///// </summary>
        ///// <param name="e"></param>
        //        public static void replaceEmptyCells(GridViewRowEventArgs e)
        //        {
        //            foreach(Control control in e.Row.Controls)
        //            {
        //                System.Web.HttpContext.Current.Response.Write(control.ToString());
        //                if (control.ToString() == "System.Web.UI.WebControls.DataControlFieldCell")
        //                {
        //DataControlFieldCell dataControlFieldCell = (DataControlFieldCell)control;
        //                    System.Web.HttpContext.Current.Response.Write(dataControlFieldCell.ContainingField.ToString())
        //                    if (Strings.IsEmptyString(dataControlFieldCell..Text))
        //                        dataControlFieldCell.Text = "&nbsp;";
        //                }
        //            }
        //        }

        #endregion
    }
}
